package me.zk;

import java.util.function.Function;
import java.util.stream.LongStream;

/**
 * @Author: zhang kai
 * @Date: 2022/07/08
 * @Description:
 */
public class Accumulator {
    public long total = 0;
    public void add(long value) { total += value; }



    public static long sideEffectSum(long n) {
        Accumulator accumulator = new Accumulator();
        LongStream.rangeClosed(1, n).forEach(accumulator::add);
        return accumulator.total;
    }

    public static void main(String[] args) {

    }
   
}


